/*************************************************************************
 *************************************************************************
 	 	 	 	 	 	 	M2SMA : DWGraphicAgent.h
 *************************************************************************
 *
 	 Copyright (C) 2011
 	 DW-2011, Steven Costiou, France
 *
 **************************************************************************
 **************************************************************************
 *
	DW super graphic agent. It is an agent that can be displayed as a
	graphic image (sprite).

	This class shall not be used directly to display a graphic static agent,
	it is designed to be inherited. Direct inherited classes can then be
	displayed.
 *
 **************************************************************************
 **************************************************************************
 *
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/
 *
 **************************************************************************
 **************************************************************************/

#ifndef DWGRAPHICAGENT_H_
#define DWGRAPHICAGENT_H_

#include "Basic2DGraphicAgent.h"

class DWGraphicAgent : public Basic2DGraphicAgent
{
	public:

		DWGraphicAgent(Engine* anEngine);
		~DWGraphicAgent();

		DWGraphicAgent(const DWGraphicAgent& aDWGraphicAgent, Engine* anEngine);

		void setFileName(const string aFileName) { filename = aFileName; };
		const string getFileName() { return filename; }

		virtual SDL_Surface* getCurrentGraphics();

		virtual void live();

	protected:

		virtual void selfCopyFrom(const Basic2DGraphicAgent& anAgent, Engine* anEngine);
		virtual bool isEqualTo(const Basic2DGraphicAgent& anAgent) const;

		/**
		 * Subclass responsability TODO : rendre cette méthode virtuelle ou bien l'interdire dans un agent immobile.
		 */
		virtual void move();

		void loadImage(const string filename);
		void display();

	private:

		void initialize();
		void initializeGraphics();
		void cleanUpSDLObjects();

	private:

		/**
		 * Surface of the loaded image that will make the sprite;
		 * i.e. that will be displayed on the screen.
		 */
		SDL_Rect* blitSurface;

		/**
		 * Loaded graphic image that form a sprite sheet.
		 */
		SDL_Surface* graphicImage;

		string filename;
};

#endif /* DWGRAPHICAGENT_H_ */

